<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
      
<ui:composition template="/restrito/template.xhtml">

<ui:define name="menu"><ui:include src="menu.xhtml"/></ui:define>

<ui:define name="corpo">
	<div class="container">
	<ui:include src="../mensagem.xhtml"/>
	
	<h:form id="f">
		<ul class="nav nav-pills">
			<li class="active"><a href="#1" data-toggle="tab" onclick="jQuery('#f\\:btAtivas').click();">Vagas ativas</a></li>
			<li class=""><a href="#2" data-toggle="tab" onclick="jQuery('#f\\:btInativas').click();">Vagas inativas</a></li>
		</ul>
		
		<a4j:commandButton id="btAtivas" action="#{consultarVagaMB.consultarVagasAtivas}" render="pnAtivas pnInativas" style="display:none;" />
		<a4j:outputPanel id="pnAtivas">
        <a4j:outputPanel id="pnResultadoAtivas" rendered="#{consultarVagaMB.abaAtiva == 1}">
			<table class="table table-striped table-bordered tabela">
			<thead>
	    		<!-- tr>
	    			<th colspan="8">Vaga ativas</th>
		    	</tr-->
				<tr>
					<th>Ident. da vaga</th>
					<th>Especialidade</th>
					<th>Nº de vagas</th>
					<th>Local</th>
					<th>Valor</th>
					<th>Prazo inscrição</th>
					<th>Nº de candidatos</th>
					<th></th>
				</tr>
			</thead>
			<tbody>
			<ui:repeat var="v" value="#{consultarVagaMB.lsVaga}" varStatus="i">
				<tr>
					<td>#{v.identificaoVaga} (#{v.idVaga})</td>
					<td>#{v.especialidade}</td>
					<td>#{v.numeroVagas}</td>
					<td>#{v.nomeFantasia}</td>
					<td><h:outputText value="#{v.valor}"><f:converter converterId="conversorDecimal"/></h:outputText></td>
					<td><h:outputText value="#{v.prazoInscricao}"><f:converter converterId="conversorData"/></h:outputText></td>
					<td>
						<h:commandLink rendered="#{v.numeroCandidatos > 0}" action="#{consultarVagaMB.visualizarCandidatosVaga}">
							<span class="badge badge-info">#{v.numeroCandidatos}</span>
							<f:param name="index" value="#{i.index}" />
						</h:commandLink>
						<a4j:outputPanel rendered="#{v.numeroCandidatos == 0}"><span class="badge">0</span></a4j:outputPanel>
					</td>
					<td>
						<a4j:commandLink value="cancelar" action="#{consultarVagaMB.cancelar}" render="pnAtivas" onclick="if(!confirm('Tem certeza que deseja cancelar essa vaga?'))return false;">
		  					<f:param name="index" value="#{i.index}" />
		  				</a4j:commandLink>
		  			</td>
			   	</tr>
		   	</ui:repeat>
		   	<c:if test="#{empty consultarVagaMB.lsVaga}">
		   		<tr>
	    			<td colspan="8">Nenhuma vaga ativa encontrada.</td>
		    	</tr>
		   	</c:if>
		   	</tbody>
			</table>
		</a4j:outputPanel>
	</a4j:outputPanel>

	<a4j:commandButton id="btInativas" action="#{consultarVagaMB.consultarVagasInativas}" render="pnAtivas pnInativas" style="display:none;" />
	<a4j:outputPanel id="pnInativas">
       	<a4j:outputPanel id="pnResultadoInativas" rendered="#{consultarVagaMB.abaAtiva == 2}">
       	<table class="table table-striped table-bordered tabela">
       	<thead>
    		<!-- tr>
    			<th colspan="7">Vaga inativas</th>
	    	</tr-->
	   		<tr>
	   			<th>Ident. da vaga</th>
	   			<th>Especialidade</th>
	   			<th>Nº de vagas</th>
	   			<th>Local</th>
	   			<th>Valor</th>
	   			<th>Prazo inscrição</th>
	   			<th></th>
	    	</tr>
    	</thead>
    	<tbody>
    	<ui:repeat var="v" value="#{consultarVagaMB.lsVagaInativa}" varStatus="i">
	   		<tr>
	   			<td>#{v.identificaoVaga} (#{v.idVaga})</td>
	   			<td>#{v.especialidade}</td>
	   			<td>#{v.numeroVagas}</td>
	   			<td>#{v.nomeFantasia}</td>
	   			<td><h:outputText value="#{v.valor}"><f:converter converterId="conversorDecimal"/></h:outputText></td>
	   			<td><h:outputText value="#{v.prazoInscricao}"><f:converter converterId="conversorData"/></h:outputText></td>
	   			<td>
	   				<h:commandLink value="editar" action="#{cadastrarVagaMB.exibirAlteracao}">
	   					<f:param name="idVaga" value="#{v.idVaga}" />
	   				</h:commandLink>
	   				|
	   				<a4j:commandLink value="excluir" action="#{consultarVagaMB.excluir}" render="pnInativas" onclick="if(!confirm('Tem certeza que deseja excluir essa vaga?'))return false;">
	   					<f:param name="index" value="#{i.index}" />
	   				</a4j:commandLink>
	   			</td>
	    	</tr>
    	</ui:repeat>
	   	<c:if test="#{empty consultarVagaMB.lsVagaInativa}">
	   		 <tr>
    			<td colspan="8">Nenhuma vaga inativa encontrada.</td>
	    	</tr>
	   	</c:if>
    	</tbody>
		</table>
		</a4j:outputPanel>
	</a4j:outputPanel>

    </h:form>
    </div>
</ui:define>
</ui:composition>
</html>
